package com.example.task1.ui.AllService.subway;

import android.os.Bundle;
import android.widget.TextView;

import com.example.task1.R;
import com.example.task1.application.MyApplication;
import com.example.task1.base.BaseActivity;
import com.example.task1.bean.SubwayAnnouncementDetailBean;
import com.example.task1.http.Api;
import com.example.task1.util.ApiResp;
import com.example.task1.util.CallBack;

import retrofit2.Call;

public class SubwayAnnouncementActivity extends BaseActivity {

    private TextView tvTitle;
    private TextView content;
    private int id;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_subway_announcement);
        id = getIntent().getIntExtra("id", 0);
        initView();
        initData();
    }

    private void initData() {
        Call<ApiResp> call = Api.api().get(MyApplication.TOKEN, "/prod-api/api/metro/notice/" + id);
        Api.send(call, SubwayAnnouncementDetailBean.class, new CallBack<SubwayAnnouncementDetailBean>() {
            @Override
            public void success(SubwayAnnouncementDetailBean data) {
                tvTitle.setText(data.getData().getTitle());
                content.setText(data.getData().getContent());
            }

            @Override
            public void error(String msg) {

            }
        });
    }

    @Override
    public String getMyTitle() {
        return "公告详情";
    }

    private void initView() {
        tvTitle = findViewById(R.id.tv_title);
        content = findViewById(R.id.content);
    }
}